#ifndef AST_EXPRESSION_MULTIPLICATIVE_EXPR_H
#define AST_EXPRESSION_MULTIPLICATIVE_EXPR_H


#include "../ASTNode.h"

class CastExpr;

/*
C99 6.5.5 
multiplicative-expression:
		cast-expression
		multiplicative-expression    *    cast-expression
		multiplicative-expression    /    cast-expression
		multiplicative-expression    %    cast-expression
*/
class MultiplicativeExpr : public ASTNode
{
public:
	enum{
		cast_expr,
		mul_expr,
		div_expr,
		mod_expr
	};
protected:
	MultiplicativeExpr(void) 
		: ASTNode(ASTNode::multiplicative_expression){};

public:
	MultiplicativeExpr(MultiplicativeExpr *pMulExpr, char cOp, CastExpr * pCastExpr)
		: ASTNode(ASTNode::multiplicative_expression)
		, m_pMulExpr(pMulExpr)
		, m_cOp(cOp)
		, m_pCastExpr(pCastExpr){switch(cOp){
	case '*':
		m_iType = mul_expr;
		break;
	case '/':
		m_iType = div_expr;
		break;
	case '%':
		m_iType = mod_expr;
		break;
	default:
		;//assert(0);
	}};
	MultiplicativeExpr(CastExpr *pSingleExpr)
		: ASTNode(ASTNode::multiplicative_expression)
		, m_iType(cast_expr)
		, m_pSingleExpr(pSingleExpr){};


	virtual ~MultiplicativeExpr(void);

	virtual void				codeGen();
protected:
	tiny_int					m_iType;
	union{
		CastExpr *		m_pSingleExpr;
		struct{
			CastExpr *	m_pCastExpr;
			char		m_cOp;
			MultiplicativeExpr *	m_pMulExpr;
		};
	};
};


#endif

